var datas = require('../../../data/data.js')
Page({
  data: {
    nodes: [{
      name: 'div',
      attrs: {
        class: 'div_class',
        style: 'line-height: 60px; color: red;'
      },
      children: [{
        type: 'text',
        text: 'Hello&nbsp;World!'
      }]
    }]
  },
  onShareAppMessage: function (res) {
    return {
      title: datas.title,
      imageUrl: datas.picture,
      path: "/pages/video/video-detail/video-detail?id=" + datas.id,
      success: function (res) {
        wx.showToast({
          title: '转发成功',
          icon: 'success',
        })
      },
    }
  },
  onLoad: function (options) {
    var that = this;
    wx.request({
      url: datas.url + "/project/highlightsAll.action",
      success: function (res) {
        for (var i = 0; i < res.data.length; i++) {
          if (res.data[i].id == options.id) {
            datas.detail = res.data[i].introduction
            datas.title = res.data[i].title
            datas.author = res.data[i].author
            datas.view = res.data[i].view
            datas.time = res.data[i].time
            datas.picture = res.data[i].picture
            datas.video = res.data[i].video
            datas.id = res.data[i].id
          }
        }
        var re = datas.detail
        re.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi, function (match) {
          ree = match.replace("<img ", "<img mode='widthFix' style='width:100%;' ")
          re = re.replace(match, ree)
        });
        datas.detail = re
        that.setData({
          picture: datas.picture,
          detail: datas.detail,
          title: datas.title,
          video: datas.video,
          author: datas.author,
          view: datas.view,
          time: datas.time
        })
      }
    })
  },
})